#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int N=1e6;
vector<ll> arr(N);
int main()
{
  ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
  ll n;cin>>n;
  for(ll i=1;i<=n;++i)
  {
    cin>>arr[i];
  }
  ll mymin=99999999999;
  sort(arr.begin()+1,arr.begin()+1+n);
  for(ll i=n;i>=1;--i)
  {
    mymin=min(mymin,arr[i]-arr[i-1]);
  }
  cout<<mymin;
  return 0;
}
